﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:common="clr-namespace:Brjnk.Common;assembly=Common"
                    xmlns:l="clr-namespace:Brjnk.GpxExplorer.Localization"
                    xmlns:my="clr-namespace:Brjnk.GpxExplorer.UI.Controls"
                    xmlns:states="clr-namespace:Brjnk.GpxExplorer.Workspace.ApplicationStates">
    <common:GenericTemplateSelector x:Key="ApplicationStateTemplateSelector">
        <common:TemplateDefinition ObjectType="{x:Type states:MovePointApplicationState}">
            <DataTemplate>
                <Grid>
                    <Grid HorizontalAlignment="Left" VerticalAlignment="Stretch">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Row="0"
                                   FontWeight="Bold"
                                   Text="{l:Loc stateMove}" />
                        <TextBlock Grid.Row="1" Text="{l:Loc stateMoveOriginalPosition}" />
                        <TextBlock Grid.Row="2" Text="{l:Loc stateMoveNewPosition}" />
                        <TextBlock Grid.Row="3" Text="{l:Loc stateMoveDistance}" />

                        <TextBlock Grid.Row="1"
                                   Grid.Column="1"
                                   Text="{Binding OriginalPosition}" />
                        <TextBlock Grid.Row="2"
                                   Grid.Column="1"
                                   FontWeight="Bold"
                                   Text="{Binding NewPosition}" />
                        <TextBlock Grid.Row="3"
                                   Grid.Column="1"
                                   Text="{Binding Distance}" />
                    </Grid>

                    <Grid HorizontalAlignment="Right" VerticalAlignment="Bottom">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0"
                                Command="{Binding UndoCommand}"
                                Content="{l:Loc stateMovePointUndo}" />
                        <Button Grid.Column="1"
                                Command="{Binding CancelCommand}"
                                Content="{l:Loc stateMovePointCancel}" />
                        <Button Grid.Row="1"
                                Grid.ColumnSpan="2"
                                Command="{Binding CompletedCommand}"
                                Content="{l:Loc stateMovePointCompleted}" />
                    </Grid>
                </Grid>
            </DataTemplate>
        </common:TemplateDefinition>
        <common:TemplateDefinition IncludeInherited="True" ObjectType="{x:Type states:InsertingToPathState}">
            <DataTemplate>
                <Grid>
                    <Grid Visibility="{Binding PointInserting, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBox Style="{StaticResource HeaderTextBoxStyle}"
                                 Text="{Binding PathName,
                                                UpdateSourceTrigger=PropertyChanged}"
                                 Visibility="{Binding CreatingNew,
                                                      Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <StackPanel Grid.Row="1"
                                    Orientation="Horizontal"
                                    Visibility="{Binding NotFirstPoint,
                                                         Converter={StaticResource BooleanToVisibilityConverter}}">
                            <TextBlock Text="{l:Loc stateInsertHeader}" />
                            <TextBlock FontWeight="Bold"
                                       Text="{l:Loc stateInsertBefore}"
                                       Visibility="{Binding BeforeInserting,
                                                            Converter={StaticResource BooleanToVisibilityConverter}}" />
                            <TextBlock FontWeight="Bold"
                                       Text="{l:Loc stateInsertBehind}"
                                       Visibility="{Binding BehindInserting,
                                                            Converter={StaticResource BooleanToVisibilityConverter}}" />
                            <my:HighlightedTextBlock Text="{Binding CurrentNumber}" />
                        </StackPanel>
                        <StackPanel Grid.Row="1"
                                    Orientation="Horizontal"
                                    Visibility="{Binding FirstPoint,
                                                         Converter={StaticResource BooleanToVisibilityConverter}}">
                            <TextBlock Text="{l:Loc stateInsertFirstPointHeader}" />
                        </StackPanel>
                        <Grid Grid.Row="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Button Grid.Column="0"
                                    Command="{Binding UndoCommand}"
                                    Content="{l:Loc stateInsertUndo}" />
                            <Button Grid.Column="2"
                                    Command="{Binding CompleteCommand}"
                                    Content="{l:Loc stateInsertComplete}" />
                            <Button Grid.Column="3"
                                    Command="{Binding CancelCommand}"
                                    Content="{l:Loc stateInsertCancel}" />
                        </Grid>
                        <StackPanel Orientation="Horizontal" Grid.Row="3"
                                    Visibility="{Binding CtrlButtonRequired, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <Image Height="20" Source="/Resources/Icons/CtrlButton.png" />
                            <TextBlock Text="{l:Loc stateInsertKeepCtrlPressed}" VerticalAlignment="Center" />
                        </StackPanel>
                    </Grid>

                    <Grid Visibility="{Binding DirectionChoosing, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.ColumnSpan="3" Text="{l:Loc stateInsertNext}" />
                        <Button Grid.Row="1"
                                Grid.Column="0"
                                Command="{Binding InsertBeforeCommand}">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{l:Loc stateInsertInsertBefore}" />
                                <my:HighlightedTextBlock Text="{Binding CurrentNumber}" />
                            </StackPanel>
                        </Button>
                        <Button Grid.Row="1"
                                Grid.Column="1"
                                Command="{Binding InsertBehindCommand}">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{l:Loc stateInsertInsertBehind}" />
                                <my:HighlightedTextBlock Text="{Binding CurrentNumber}" />
                            </StackPanel>
                        </Button>
                        <Button Grid.Row="1"
                                Grid.Column="2"
                                Command="{Binding CompleteCommand}"
                                Content="{l:Loc stateInsertComplete}" />
                        <Button Grid.Row="1"
                                Grid.Column="3"
                                Command="{Binding CancelCommand}"
                                Content="{l:Loc stateInsertCancel}" />
                    </Grid>
                </Grid>
            </DataTemplate>
        </common:TemplateDefinition>
    </common:GenericTemplateSelector>
</ResourceDictionary>